/**
 * Creates a new file with the given name in the given location (parent folder
 * path relative to the companyhome) with given content.
 */
function main() {
	// parse json object
	var name = args.name;
	var path = args.location;
//	var content = args.content;
	var content = json;

	// find parent folder scriptNode
	var pathParts = path.split("/");

	var folderNode = companyhome;

	for ( var i = 0; i < pathParts.length; i++) {
		if (pathParts[i] != "" || pathParts[i] != null) {
			// get root folder
			var deeperFolder = folderNode.childByNamePath(pathParts[i]);

			if (deeperFolder == null) {
				deeperFolder = folderNode.createFolder(pathParts[i]);
			}
			folderNode = deeperFolder;
		}
	}

	// get file or create if not exist
	var newFile=folderNode.childByNamePath(name);
	if(newFile == null){
		newFile = folderNode.createFile(name);
	}

	// set content of new file
	if (content != null) {
		newFile.content = content;
	}

}

main();